<script setup>
import { useRouter } from 'vue-router';
const router = useRouter()
const props = defineProps({
    list: Array
})
const toDetail= (id)=>{
    router.push('/detail?id='+id)
}
</script>
<template>
    <div class="movie-info">
        <div class="mi-list">
            <div class="mi-item" v-for="item in props.list" :key="item.id" @click="toDetail(item.id)">
                <div class="mi-poster">
                    <img :src="item.img" alt="">
                </div>
                <div class="mi-intro">
                    <div class="info">
                        <h1>{{ item.nm }}</h1>
                        <p v-if="item.sc !== 0">点映评 <span>{{ item.sc }}</span></p>
                        <p v-if="item.sc == 0"><span>{{ item.wish }}</span>人想看</p>
                        <p class="star">主演:{{ item.star }}</p>
                        <p>{{ item.rt }}上映</p>
                    </div>
                    <div class="btn" v-if="item.showStateButton && item.showStateButton.color" :style="{ backgroundColor: item.showStateButton.color }">
                        {{ item.showStateButton.content }}
                    </div>
                    <div class="btn" v-if="!item.showStateButton" :style="{ backgroundColor: 'orange' }">
                        想看
                    </div>
                </div>
            </div>
        </div>
    </div>
</template>

<style lang="scss" scoped>
.movie-info {
    margin-top: 15px;

    .mi-list {
        .mi-item {
            display: flex;
            margin-bottom: 10px;

            .mi-poster {
                width: 64px;
                height: 90px;

                img {
                    width: 100%;
                    height: 100%;
                }
            }

            .mi-intro {
                display: flex;
                width: 79%;
                margin-left: 10px;
                justify-content: space-between;
                align-items: center;
                padding: 10px 0;
                border-bottom: 1px solid #f0f0f0;

                .info {
                    max-width: 75%;
                    h1 {
                        font-size: 17px;
                        color: #333;
                        font-weight: 700;
                    }

                    p {
                        font-size: 13px;
                        color: #666;
                        margin-top: 7px;

                        span {
                            color: #faaf00;
                            font-weight: 800;
                        }
                    }

                    .star {
                        width: 100%;
                        overflow: hidden;
                        text-overflow: ellipsis;
                        white-space: nowrap;
                        word-break: break-all;
                    }
                }

                .btn {
                    height: 20px;
                    padding: 5px 15px;
                    color: white;
                    border-radius: 18px;
                    font-size: 13px;
                    line-height: 20px;
                }
            }
        }
    }
}
</style>